knitr::opts_chunk$set(echo=FALSE)
#knitr::knit_hooks$set(optipng = knitr::hook_optipng)
#library(xlsx)
library("openxlsx")
library(plyr)
library(dplyr)
library(ggbeeswarm)
library(reshape2)
library(data.table)
library(ggplot2)
library(TCGAbiolinks)
library(SummarizedExperiment)
library(ggsignif)
library(survminer)
library(survival)
library(kableExtra)
library(Hmisc)
library(stringr)
library(maxstat)
library(qwraps2)
options(qwraps2_markup = "markdown")
library(DT)
library(ggrepel)
lm_eqn <- function(df,y1,x1){
    lm_eqn_res <- eval(parse(text=paste0("lm(`",y1,"` ~ ",x1,", ",df,")")))
    eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2, 
         list(a = format(unname(coef(lm_eqn_res)[1]), digits = 2),
              b = format(unname(coef(lm_eqn_res)[2]), digits = 2),
             r2 = format(summary(lm_eqn_res)$r.squared, digits = 3)))
    as.character(as.expression(eq));
}

wb <- createWorkbook()
sigStyle <- createStyle(fontColour = "#000000", bgFill = "#cd5c5c")
emptyStyle <- createStyle(fontColour = "#000000", bgFill =  "#FFFFFF")
#library(tables)

Methods

The expression levels of the gene is compared to the purity of the samples and the estimated levels of tumor-infiltrating immune cells.
 
The purity is estimated two ways:
1, based on Cancer DNA Fraction
2, using ESTIMATE (an RNA-Seq-based method)
The levels of tumor-infiltrating immune cells are estimated using:
1, CIBERSORT absolute
2, CIBERSORT relative
3, TIMER
4, method presented by Danaher et al.
5, mMCP counter
6, xCell
 

#IMMUNE
estimate <- read.table("./data/41467_2015_BFncomms9971_MOESM1236_ESM.txt", sep="\t", header=T, stringsAsFactors = F)
estimate <- estimate[!is.na(estimate$ESTIMATE),]
estimate$PatientID_estimate <- substr(estimate$Sample.ID,1,12)

purity <- fread("./data/TCGA_mastercalls.abs_tables_JSedit.fixed.txt", data.table=F)
purity$PatientID_short <- substr(purity$array,1,12)
purity<-purity[!duplicated(purity$PatientID_short),]
purity$contamination <- 1-purity$"Cancer DNA fraction"

timer <- read.table("./data/13059_2016_1028_MOESM3_ESM.txt", header=T, check.names=T, stringsAsFactors=F, sep="\t")
timer = timer[grepl("-01A|-01B",timer$SampleID_timer),]
timer$PatientID_timer <- substr(timer$SampleID_timer,1,12)


danaher <- read.table("./data/40425_2017_215_MOESM4_ESM.csv", header=T, check.names=T, stringsAsFactors=F, sep=",",row.names = 1)
danaher <- danaher[grepl('01A|01B|01C',rownames(danaher)),]
danaher <- danaher[ order(row.names(danaher)), ]
danaher$PatientID_danaher <- substr(rownames(danaher),1,12)
danaher$PatientID_danaher <- gsub('\\.','-',danaher$PatientID_danaher)
danaher <- danaher[!duplicated(danaher$PatientID_danaher),]

leuk <- read.table("./data/TCGA_all_leuk_estimate.masked.20170107.tsv", header=F, stringsAsFactors=F, sep="\t")
leuk$PatientID_leuk <- substr(leuk$V2,1,12)

load("./data/TCGA_CIBERSORT_ABS.RData")
results_htseq_abs$CD8.to.Treg_prop <- results_htseq_abs$T.cells.CD8/results_htseq_abs$T.cells.regulatory..Tregs.
results_htseq_abs$CD4.naive.to.Treg_prop <- results_htseq_abs$T.cells.CD4.naive/results_htseq_abs$T.cells.regulatory..Tregs.
results_htseq_abs$T.cells.CD4.memory.resting.to.Treg_prop <- results_htseq_abs$T.cells.CD4.memory.resting/results_htseq_abs$T.cells.regulatory..Tregs.
results_htseq_abs$T.cells.CD4.memory.activated.to.Treg_prop <- results_htseq_abs$T.cells.CD4.memory.activated/results_htseq_abs$T.cells.regulatory..Tregs.

ciber=fread('./data/TCGA.Kallisto.fullIDs.cibersort.relative.tsv', data.table = F)
ciber$SampleID=gsub('\\.','-', substr(ciber$SampleID,1,12))
ciber=ciber[,c(1,3:24)]
summary_table = list()
mycancer='BRCA'
subset00=params$selected_data[[mycancer]]
for(mycancer in  c("LumA","LumB","Her2","Normal","Basal")){
subset1=subset00[subset00$Subtype_mRNA==mycancer, ]
subset1$submitter_id=as.character(subset1$submitter_id)

    cat('\n')  
    cat('\n') 
      cat(paste0('# Breast cc., ',mycancer)) 
      cat('\n') 

    cat('\n')  
    cat('\n') 
      cat('## Correlation with purity') 
      cat('\n') 
      
merged <- merge(purity,subset1, by.x="PatientID_short", by.y="submitter_id")
cor_POLQ <- cor(merged[,params$selected_gene],merged$"Cancer DNA fraction",use="complete.obs")
cor_POLQ1 = round(cor_POLQ,2)

p1 <- ggplot(merged)
p1 <- p1 + geom_point(aes(x = `Cancer DNA fraction`, y = .data[[params$selected_gene]]))
p1 <- p1 + xlab("Cancer DNA fraction")+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged[,"Cancer DNA fraction"],na.rm=T)*0.7, y=max(merged[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes(x=`Cancer DNA fraction`, y=.data[[params$selected_gene]]), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

    cat('\n')  
    cat('\n') 
      cat('## Correlation with purity - method: ESTIMATE, based on RNA-Seq data') 
      cat('\n') 
      
      
merged_estimate <- merge(estimate,subset1, by.x="PatientID_estimate", by.y="submitter_id")
if(nrow(merged_estimate)>9){
cor_POLQ <- cor(merged_estimate[,params$selected_gene],merged_estimate$ESTIMATE,use="complete.obs")
cor_POLQ2 = round(cor_POLQ,2)

p1 <- ggplot(merged_estimate)
p1 <- p1 + geom_point(aes(x=ESTIMATE, y=.data[[params$selected_gene]]))
p1 <- p1 +xlab("purity")+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", ESTIMATE"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged_estimate[,"ESTIMATE"],na.rm=T)*0.7, y=max(merged_estimate[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes(x=ESTIMATE, y=.data[[params$selected_gene]]), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (CIBERSORT ABSOLUTE)') 
      cat('\n')
      
merged <- merge(results_htseq_abs, subset1, by.x="row.names", by.y="submitter_id")
if(nrow(merged)>9){
nocommnet <- sapply(colnames(results_htseq_abs)[1:22], function(x) {
cor_POLQ <- cor(merged[,params$selected_gene],merged[,x],use="complete.obs")
cor_POLQ3 = round(cor_POLQ,2)

p1 <- ggplot(merged)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(x)+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", CIBERSORTabs"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged[,x],na.rm=T)*0.7, y=max(merged[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQ3
})
cor_POLQ3=nocommnet
} else {
cor_POLQ3 = rep(NA, 22) 
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (CIBERSORT relative)') 
      cat('\n')

merged <- merge(ciber, subset1, by.x="SampleID", by.y="submitter_id")
if(nrow(merged)>9){

nocommnet <- sapply(colnames(ciber)[2:23], function(x) {
cor_POLQ <- cor(merged[,params$selected_gene],merged[,x],use="complete.obs")
cor_POLQ8 = round(cor_POLQ,2)

p1 <- ggplot(merged)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(x)+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", CIBERSORTrel"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged[,x],na.rm=T)*0.7, y=max(merged[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQ8
})
cor_POLQ8=nocommnet
} else {
cor_POLQ8 = rep(NA, 22) 
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (TIMER)') 
      cat('\n') 
      
merged_timer <- merge(timer, subset1, by.x="PatientID_timer", by.y="submitter_id")
if(nrow(merged_timer)>9){
nocommnet2 <- sapply(c("B.cells","T.cells..CD4..","T.cells..CD8..","Neutrophils","Macrophages","Dentritic.cells"), function(x) {
cor_POLQ <- cor(merged_timer[,params$selected_gene],merged_timer[,x],use="complete.obs")
cor_POLQtmp = round(cor_POLQ,2)

myxlabel <- gsub("\\..CD4.."," (CD4+)",x)
myxlabel <- gsub("\\..CD8.."," (CD8+)",myxlabel)
myxlabel <- gsub("\\.y","",myxlabel); myxlabel <- gsub("\\.","-",myxlabel)
p1 <- ggplot(merged_timer)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(myxlabel)
p1 <- p1 + ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", TIMER"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged_timer[,x],na.rm=T)*0.7, y=max(merged_timer[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQtmp
})
cor_POLQ4=nocommnet2
} else {
cor_POLQ4 = rep(NA, 6) 
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (Danaher)') 
      cat('\n') 
      
merged_danaher <- merge(danaher, subset1, by.x="PatientID_danaher", by.y="submitter_id")
if(nrow(merged_danaher)>9){
nocommnet3 <- sapply(c("alltottils", "B.cells", "DC", "Macrophages", "Exhausted.CD8", "T.cells", "CD8.T.cells", "Neutrophils", "Cytotoxic.cells", "Treg", "NK.CD56dim.cells", "Mast.cells", "NK.cells", "Th1.cells"), function(x) {
cor_POLQ <- cor(merged_danaher[,params$selected_gene],merged_danaher[,x],use="complete.obs")
cor_POLQ5 = round(cor_POLQ,2)

myxlabel <- gsub("\\..CD4.."," (CD4+)",x)
myxlabel <- gsub("\\..CD8.."," (CD8+)",myxlabel)
myxlabel <- gsub("\\.y","",myxlabel); myxlabel <- gsub("\\.","-",myxlabel)

p1 <- ggplot(merged_danaher)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(myxlabel)
p1 <- p1 + ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", Danaher"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged_danaher[,x],na.rm=T)*0.7, y=max(merged_danaher[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQ5
})
cor_POLQ5=nocommnet3
} else {
cor_POLQ5=rep(NA,14)  
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with Leukocyte Fraction') 
      cat('\n')
      
merged_leuk <- merge(leuk, subset1, by.x="PatientID_leuk", by.y="submitter_id")
if(nrow(merged_leuk)>9){
cor_POLQ <- cor(merged_leuk[,params$selected_gene],merged_leuk[,"V3"],use="complete.obs")
cor_POLQ6 = round(cor_POLQ,2)

p1 <- ggplot(merged_leuk)
p1 <- p1 + geom_point(aes_string(x="V3", y=params$selected_gene))
p1 <- p1 + xlab("Leukocyte Fraction")
p1 <- p1 + ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", LF"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged_leuk[,"V3"],na.rm=T)*0.7, y=max(merged_leuk[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x="V3", y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)


cor_POLQ6
} else {
cor_POLQ6=NA
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (mMCP counter)') 
      cat('\n')

load(paste0("./data/MCPcounter_BRCA.RData"))

mcp_counter2=t(as.data.frame(mcp_counter[,-1]))
colnames(mcp_counter2)=gsub("\\+","pos", gsub('\\ |/','.', mcp_counter$cell_type))
merged <- merge(mcp_counter2, subset1, by.x="row.names", by.y="submitter_id")
if(nrow(merged)>9){

nocommnet <- sapply(colnames(mcp_counter2), function(x) {
cor_POLQ <- cor(merged[,params$selected_gene],merged[,x],use="complete.obs")
cor_POLQ7 = round(cor_POLQ,2)

p1 <- ggplot(merged)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(x)+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", MCPcounter"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged[,x],na.rm=T)*0.7, y=max(merged[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQ7
})
cor_POLQ7=nocommnet
} else {
cor_POLQ7 = rep(NA, 22) 
}

    cat('\n')  
    cat('\n') 
      cat('## Correlation with immune cells (xCell)') 
      cat('\n')

load(paste0("./data/xCell_BRCA.RData"))

xCell2=t(as.data.frame(xCell[,-1]))
colnames(xCell2)=gsub("\\+","pos", gsub('\\ |/','.', xCell$cell_type))
colnames(xCell2)=gsub("\\(|\\)|-","", colnames(xCell2))
merged <- merge(xCell2, subset1, by.x="row.names", by.y="submitter_id")
if(nrow(merged)>9){
nocommnet <- sapply(colnames(xCell2), function(x) {
cor_POLQ <- cor(merged[,params$selected_gene],merged[,x],use="complete.obs")
cor_POLQ9 = round(cor_POLQ,2)

p1 <- ggplot(merged)
p1 <- p1 + geom_point(aes_string(x=x, y=params$selected_gene))
p1 <- p1 + xlab(x)+ylab(paste0(params$selected_gene," expression (TPM)"))
p1 <- p1 + ggtitle(paste0("All patients, ",mycancer,", xCell"))
data.label <- data.frame(label=paste("Pearson r = ", round(cor_POLQ,2)," (r2 = ", round(cor_POLQ*cor_POLQ,2),")",sep=""), x=max(merged[,x],na.rm=T)*0.7, y=max(merged[,params$selected_gene])*0.7)
p1 <- p1 + geom_text(data = data.label, aes(x = x , y = y , label = label ),hjust=0,size=5)
p1 <- p1 + geom_smooth(aes_string(x=x, y=params$selected_gene), method=lm, se=FALSE, color="black")
p1 <- p1 + theme_classic()
p1 <- p1 + theme(axis.text = element_text(colour = "black", size = rel(0.7)), axis.ticks = element_line(colour = "black", size = 0.25), plot.margin=margin(10,10,6,10), plot.title=element_text(colour = "black", size = rel(1)),legend.justification=c(1,1),legend.position=c(1,1),legend.title = element_blank(),legend.key = element_rect(fill = "gray"))
print(p1)

cor_POLQ9
})
cor_POLQ9=nocommnet
} else {
cor_POLQ9 = rep(39) 
}

#cor_POLQ1 puritu
#cor_POLQ2 estimate
#cor_POLQ3 CIBERSORT
#cor_POLQ4 Timer, 6
#cor_POLQ5 Danaher
#cor_POLQ6 LF
#cor_POLQ7 MCP
#cor_POLQ8 CIBERSORT rel

summary_table[[mycancer]]= c(cor_POLQ1, cor_POLQ2, cor_POLQ3, cor_POLQ4, cor_POLQ5, cor_POLQ6, cor_POLQ7, cor_POLQ8,cor_POLQ9)
}

Breast cc., LumA

Correlation with purity

Correlation with purity - method: ESTIMATE, based on RNA-Seq data

Correlation with immune cells (CIBERSORT ABSOLUTE)

Correlation with immune cells (CIBERSORT relative)

Correlation with immune cells (TIMER)

Correlation with immune cells (Danaher)

Correlation with Leukocyte Fraction

Correlation with immune cells (mMCP counter)

Correlation with immune cells (xCell)

Breast cc., LumB

Correlation with purity

Correlation with purity - method: ESTIMATE, based on RNA-Seq data

Correlation with immune cells (CIBERSORT ABSOLUTE)

Correlation with immune cells (CIBERSORT relative)

Correlation with immune cells (TIMER)

Correlation with immune cells (Danaher)

Correlation with Leukocyte Fraction

Correlation with immune cells (mMCP counter)

Correlation with immune cells (xCell)

Breast cc., Her2

Correlation with purity

Correlation with purity - method: ESTIMATE, based on RNA-Seq data

Correlation with immune cells (CIBERSORT ABSOLUTE)

Correlation with immune cells (CIBERSORT relative)

Correlation with immune cells (TIMER)

Correlation with immune cells (Danaher)

Correlation with Leukocyte Fraction

Correlation with immune cells (mMCP counter)

Correlation with immune cells (xCell)

Breast cc., Normal

Correlation with purity

Correlation with purity - method: ESTIMATE, based on RNA-Seq data

Correlation with immune cells (CIBERSORT ABSOLUTE)

Correlation with immune cells (CIBERSORT relative)

Correlation with immune cells (TIMER)

Correlation with immune cells (Danaher)

Correlation with Leukocyte Fraction

Correlation with immune cells (mMCP counter)

Correlation with immune cells (xCell)

Breast cc., Basal

Correlation with purity

Correlation with purity - method: ESTIMATE, based on RNA-Seq data

Correlation with immune cells (CIBERSORT ABSOLUTE)

Correlation with immune cells (CIBERSORT relative)

Correlation with immune cells (TIMER)

Correlation with immune cells (Danaher)

Correlation with Leukocyte Fraction

Correlation with immune cells (mMCP counter)

Correlation with immune cells (xCell)

summary_table2 = do.call("rbind",summary_table)
colnames(summary_table2)=paste0(c("purity","purity.ESTIMATE",rep("CIBERSORT.",22), rep("TIMER.",6), rep("Danaher",14), "Leukocyte.Fraction", rep("MCPcounter",11),rep("CIBERSORTrel.",22),rep("xCell.",39)),colnames(summary_table2))

wb <- createWorkbook()
addWorksheet(wb, "immune_cor")
#sigStyle <- createStyle(fontColour = "#000000", bgFill = "#cd5c5c")
#emptyStyle <- createStyle(fontColour = "#000000", bgFill =  "#FFFFFF")
writeData(wb, "immune_cor", summary_table2, rowNames = TRUE)
#conditionalFormatting(wb, "kallisto", cols=5, rows = 1:nrow(merged_table_full), rule="<0.05", style = sigStyle)
#conditionalFormatting(wb, "kallisto", cols=9, rows = 1:nrow(merged_table_full), rule='=""', style = emptyStyle)
#saveWorkbook(wb, "/.data/tmp.xlsx", overwrite = TRUE)